//
//  WCNCommentItemTCell.m
//  WCN
//
//  Created by 杨鑫 on 15/6/2.
//  Copyright (c) 2015年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCNCommentItemTCell.h"

@interface WCNCommentItemTCell ()

@property (weak, nonatomic) IBOutlet UIImageView *star1;
@property (weak, nonatomic) IBOutlet UIImageView *star2;
@property (weak, nonatomic) IBOutlet UIImageView *star3;
@property (weak, nonatomic) IBOutlet UIImageView *star4;
@property (weak, nonatomic) IBOutlet UIImageView *star5;

@property (weak, nonatomic) IBOutlet UILabel *score;

@end

@implementation WCNCommentItemTCell

- (void)awakeFromNib {
    // Initialization code
    
    [self setSeparatorInset:UIEdgeInsetsZero];
    if ([self respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
        [self setPreservesSuperviewLayoutMargins:NO];
    }
    if ([self respondsToSelector:@selector(setLayoutMargins:)]) {
        [self setLayoutMargins:UIEdgeInsetsZero];
    }
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setScoreValue:(float)score
{
    self.score.text = [NSString stringWithFormat:@"%.1f分", score];
    
    int count = score;
    switch (count) {
        case 5:
            self.star5.image = [UIImage imageNamed:@"Star_show"];
        case 4:
            self.star4.image = [UIImage imageNamed:@"Star_show"];
        case 3:
            self.star3.image = [UIImage imageNamed:@"Star_show"];
        case 2:
            self.star2.image = [UIImage imageNamed:@"Star_show"];
        case 1:
            self.star1.image = [UIImage imageNamed:@"Star_show"];
        default:
            break;
    }
    
    if (score > count) {
        switch (count) {
            case 4:
                self.star5.image = [UIImage imageNamed:@"Star_show_half"];
                break;
            case 3:
                self.star4.image = [UIImage imageNamed:@"Star_show_half"];
                break;
            case 2:
                self.star3.image = [UIImage imageNamed:@"Star_show_half"];
                break;
            case 1:
                self.star2.image = [UIImage imageNamed:@"Star_show_half"];
                break;
            case 0:
                self.star1.image = [UIImage imageNamed:@"Star_show_half"];
                break;
            default:
                break;
        }
    }
}

@end
